package com.dragon.refect.error;

/**
 * @author dragon
 * @since 2019/12/12
 */
public class DeadLock {

    public static void main(String[] args) {
        new Thread(() -> {
            try {
                A.a();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "thread A").start();
        new Thread(() -> {
            try {
                B.b();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "thread B").start();
    }
}


class A {

    public static synchronized void a() throws InterruptedException {
        Thread.sleep(5000);
        B.b();
    }
}

class B {
    public static synchronized void b() throws InterruptedException {
        Thread.sleep(5000);
        A.a();
    }

}
